package phoenix.web.test_suites.clickandflirt.critical;

import java.util.ArrayList;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import phoenix.core.base.TestSuiteBase;
import phoenix.core.data_models.TestUserDataModel;
import phoenix.core.data_models.UserProfileDataModel;
import phoenix.web.test_objects.BackendTests;
import phoenix.web.test_objects.FunnelTests;
import phoenix.web.test_objects.MessengerTests;
import phoenix.web.test_objects.PaymentRedirectionsTests;
import phoenix.web.test_objects.RegistrationTests;
import phoenix.web.test_objects.UserPageTests;

/**
 * Created by AlexGolovko on 15.09.2014.
 */
public class MessengerTS extends TestSuiteBase
{
	private final RegistrationTests registrationTests = new RegistrationTests(phoenix);
	private final BackendTests backendTests = new BackendTests(phoenix);
	private final FunnelTests funnelTests = new FunnelTests(phoenix);
	private final MessengerTests messengerTests = new MessengerTests(phoenix);
	private final PaymentRedirectionsTests paymentRedirectionsTests = new PaymentRedirectionsTests(phoenix);

	@DataProvider
	public Object[][] messengerNotificationFreeData()
	{
		return messengerTests.dataProviders.messengerNotificationFreeData();
	}

	@DataProvider
	public Object[][] messengerNotificationPaidData()
	{
		return messengerTests.dataProviders.messengerNotificationPaidData();
	}

	@DataProvider
	public Object[][] userDataProvider()
	{
		return messengerTests.dataProviders.registrationDataMale();
	}

	@DataProvider
	public Object[][] paymentReceiveChatData()
	{
		return paymentRedirectionsTests.dataProviders.paymentReceiveChatData();
	}

	@DataProvider
	public Object[][] paymentAnswerChatData()
	{
		return paymentRedirectionsTests.dataProviders.paymentAnswerChatData();
	}

	@DataProvider
	public Object[][] paymentHotUserData()
	{
		return paymentRedirectionsTests.dataProviders.paymentHotUserData();
	}

	@DataProvider
	public Object[][] paymentFreeCommunicationData()
	{
		return paymentRedirectionsTests.dataProviders.paymentFreeCommunicationData();
	}

	@DataProvider
	public Object[][] paymentTwoMessagesData()
	{
		return paymentRedirectionsTests.dataProviders.paymentTwoMessagesData();
	}

	@DataProvider
	public Object[][] paymentSpecialDeliveryData()
	{
		return paymentRedirectionsTests.dataProviders.paymentSpecialDeliveryData();
	}

	@DataProvider
	public Object[][] fiveMessagesData()
	{
		return messengerTests.dataProviders.fiveMessagesData();
	}

	@DataProvider
	public Object[][] paymentFreeCommunicationMessengerData()
	{
		return paymentRedirectionsTests.dataProviders.paymentFreeCommunicationMessengerData();
	}

	@Test(dataProvider = "userDataProvider", groups = { "registration" }, priority = 1, enabled = true)
	public void messengerFreeUserRedirects(String p_userGender, String p_userEmail, String p_userPassword, String p_userBirthDay,
		String p_userBirthMonth, String p_userBirthYear, String p_screenName, UserProfileDataModel.LookingFor p_lookingForParams,
		UserProfileDataModel.AboutMe p_aboutMeParams)
	{
		registrationTests.registrationTest(p_userGender, p_userEmail, p_userPassword, p_userBirthDay, p_userBirthMonth, p_userBirthYear);
		backendTests.getUserDataTest(testUser().getEmail());
		funnelTests.confirmationTest();
		funnelTests.funnelTest(p_screenName, p_lookingForParams, p_aboutMeParams);
	}

	@Test(dependsOnMethods = "messengerFreeUserRedirects", priority = 2, dataProvider = "paymentTwoMessagesData", enabled = true)
	public void redirectsTwoMessagesTest(String p_messageKey, TestUserDataModel p_userSender, TestUserDataModel p_userReciever)
	{
		messengerTests.twoMessagesTest(p_messageKey, p_userSender, p_userReciever);
	}

	// https://redmine.platformphoenix.com/issues/142400
	@Test(dependsOnMethods = "messengerFreeUserRedirects", priority = 3, dataProvider = "paymentReceiveChatData", enabled = false)
	public void receiveChatAtProfileTest(String p_messageKey, TestUserDataModel p_userSender, TestUserDataModel p_userRecipient)
	{
		messengerTests.recieveChatAtProfileTest(p_messageKey, p_userSender, p_userRecipient);
	}

	@Test(dependsOnMethods = "messengerFreeUserRedirects", priority = 4, dataProvider = "paymentReceiveChatData", enabled = true)
	public void receiveChatAtSearchTest(String p_messageKey, TestUserDataModel p_userSender, TestUserDataModel p_userRecipient)
	{
		messengerTests.recieveChatAtSearchTest(p_messageKey, p_userSender, p_userRecipient);
	}

	@Test(dependsOnMethods = "messengerFreeUserRedirects", priority = 5, dataProvider = "paymentAnswerChatData", enabled = true)
	public void redirectsAnswerChatTest(String p_messageKey, TestUserDataModel p_userSender, TestUserDataModel p_userRecipient)
	{
		messengerTests.answerChatTest(p_messageKey, p_userSender, p_userRecipient);
	}

	@Test(dependsOnMethods = "messengerFreeUserRedirects", priority = 6, dataProvider = "paymentHotUserData", enabled = true)
	public void redirectsHotUserMessageTest(TestUserDataModel p_userHot)
	{
		messengerTests.hotUserMessageTest(p_userHot);
	}

	@Test(dependsOnMethods = "messengerFreeUserRedirects", groups = {
		"interaction" }, priority = 8, dataProvider = "fiveMessagesData", enabled = true, alwaysRun = true)
	public void redirectsFiveMessagesLimitTest(String p_userGender, String p_userEmail, String p_userPassword, String p_userBirthDay,
		String p_userBirthMonth, String p_userBirthYear, String p_screenName, UserProfileDataModel.LookingFor p_lookingForParams,
		UserProfileDataModel.AboutMe p_aboutMeParams, String p_messageKey, TestUserDataModel p_sender, ArrayList<TestUserDataModel> p_userRecipient)
	{
		registrationTests.registrationTest(p_userGender, p_userEmail, p_userPassword, p_userBirthDay, p_userBirthMonth, p_userBirthYear);
		backendTests.getUserDataTest(testUser().getEmail());
		funnelTests.confirmationTest();
		funnelTests.funnelTest(p_screenName, p_lookingForParams, p_aboutMeParams);
		messengerTests.fiveMessagesLimitTest(p_messageKey, p_sender, p_userRecipient);
	}

	@Test(dependsOnMethods = "redirectsFiveMessagesLimitTest", groups = {
		"interaction" }, dataProvider = "messengerNotificationFreeData", priority = 9, enabled = true, alwaysRun = true)
	public void messageFreeNotificationTest(String p_userGender, String p_userEmail, String p_userPassword, String p_userBirthDay,
		String p_userBirthMonth, String p_userBirthYear, String p_screenName, UserProfileDataModel.LookingFor p_lookingForParams,
		UserProfileDataModel.AboutMe p_aboutMeParams, TestUserDataModel[] p_user, ArrayList<Integer> fixtureOrderAtList)
	{
		registrationTests.registrationTest(p_userGender, p_userEmail, p_userPassword, p_userBirthDay, p_userBirthMonth, p_userBirthYear);
		backendTests.getUserDataTest(testUser().getEmail());
		funnelTests.confirmationTest();
		funnelTests.funnelTest(p_screenName, p_lookingForParams, p_aboutMeParams);
		messengerTests.messageNotificationTest(p_user, fixtureOrderAtList);
	}

	@Test(dependsOnMethods = "messageFreeNotificationTest", dataProvider = "messengerNotificationPaidData", priority = 10, enabled = true, alwaysRun = true)
	public void messengerPaidUserAlerts(String p_gender, String p_email, String p_password, String p_day,
		String p_month, String p_year, String p_name, UserProfileDataModel.LookingFor p_lookingFor,
		UserProfileDataModel.AboutMe p_aboutMeParams, TestUserDataModel[] p_user, ArrayList<Integer> fixtureOrderAtList)
	{
		registrationTests.registrationTest(p_gender, p_email, p_password, p_day, p_month, p_year);
		backendTests.getUserDataTest(testUser().getEmail());
		funnelTests.confirmationTest();
		funnelTests.funnelTest(p_name, p_lookingFor, p_aboutMeParams);
		backendTests.makeUserPaid(testUser());
		messengerTests.messageNotificationTest(p_user, fixtureOrderAtList);
	}

	@Test(priority = 12, dependsOnMethods = "messengerPaidUserAlerts", dataProvider = "paymentFreeCommunicationMessengerData",
		enabled = true)
	public void redirectsPaidFreeCommunicationMessengerLinkTest(String p_messageKey, TestUserDataModel p_userSender, TestUserDataModel p_userRecipient)
	{
		messengerTests.freeCommunicationMessengerLinkTest(p_messageKey, p_userSender, p_userRecipient);
	}

	@Test(priority = 13, dependsOnMethods = "messengerPaidUserAlerts", dataProvider = "paymentSpecialDeliveryData", enabled = true)
	public void redirectsPaidSpecialDeliveryMessengerLinkTest(TestUserDataModel p_userRecipient)
	{
		messengerTests.specialDeliviryMessengerLinkTest(p_userRecipient);
	}

}
